@@ -55,7 +55,9 @@ class GroupInfo(BaseModelMixin): |
||
55 | 55 |
verbose_name = _(u'groupinfo') |
56 | 56 |
verbose_name_plural = _(u'groupinfo') |
57 | 57 |
|
58 |
- unique_together = (('session_id', 'group_from'),) |
|
58 |
+ unique_together = ( |
|
59 |
+ ('session_id', 'group_from'), |
|
60 |
+ ) |
|
59 | 61 |
|
60 | 62 |
def __unicode__(self): |
61 | 63 |
return unicode(self.group_id) |
@@ -174,7 +176,9 @@ class GroupUserInfo(BaseModelMixin): |
||
174 | 176 |
verbose_name = _(u'groupuserinfo') |
175 | 177 |
verbose_name_plural = _(u'groupuserinfo') |
176 | 178 |
|
177 |
- unique_together = (('group_id', 'user_id'),) |
|
179 |
+ unique_together = ( |
|
180 |
+ ('group_id', 'user_id'), |
|
181 |
+ ) |
|
178 | 182 |
|
179 | 183 |
def __unicode__(self): |
180 | 184 |
return unicode(self.pk) |
@@ -260,7 +264,9 @@ class GroupPhotoInfo(BaseModelMixin, LensmanTypeMixin): |
||
260 | 264 |
verbose_name = _(u'groupphotoinfo') |
261 | 265 |
verbose_name_plural = _(u'groupphotoinfo') |
262 | 266 |
|
263 |
- unique_together = (('group_id', 'user_id', 'photo_md5'),) |
|
267 |
+ unique_together = ( |
|
268 |
+ ('group_id', 'user_id', 'photo_md5'), |
|
269 |
+ ) |
|
264 | 270 |
|
265 | 271 |
def __unicode__(self): |
266 | 272 |
return unicode(self.pk) |
@@ -345,7 +351,9 @@ class GroupPhotoOrderInfo(BaseModelMixin): |
||
345 | 351 |
verbose_name = _(u'groupphotoorderinfo') |
346 | 352 |
verbose_name_plural = _(u'groupphotoorderinfo') |
347 | 353 |
|
348 |
- unique_together = (('group_id', 'session_id', 'user_id', 'photo_id', 'lensman_photo_id'),) |
|
354 |
+ unique_together = ( |
|
355 |
+ ('group_id', 'session_id', 'user_id', 'photo_id', 'lensman_photo_id'), |
|
356 |
+ ) |
|
349 | 357 |
|
350 | 358 |
def __unicode__(self): |
351 | 359 |
return unicode(self.pk) |
@@ -409,7 +417,9 @@ class PhotoThumbUpInfo(BaseModelMixin): |
||
409 | 417 |
verbose_name = _(u'photothumbupinfo') |
410 | 418 |
verbose_name_plural = _(u'photothumbupinfo') |
411 | 419 |
|
412 |
- unique_together = (('photo_id', 'user_id'),) |
|
420 |
+ unique_together = ( |
|
421 |
+ ('photo_id', 'user_id'), |
|
422 |
+ ) |
|
413 | 423 |
|
414 | 424 |
def __unicode__(self): |
415 | 425 |
return unicode(self.pk) |
@@ -348,6 +348,7 @@ class SaleclerkInfo(BaseModelMixin, SexModelMixin): |
||
348 | 348 |
class Meta: |
349 | 349 |
verbose_name = _(u'经销商销售员信息') |
350 | 350 |
verbose_name_plural = _(u'经销商销售员信息') |
351 |
+ |
|
351 | 352 |
unique_together = ( |
352 | 353 |
('unionid', 'brand_id'), |
353 | 354 |
) |
@@ -393,6 +394,7 @@ class BrandModelDistributorPriceInfo(BaseModelMixin): |
||
393 | 394 |
class Meta: |
394 | 395 |
verbose_name = _(u'品牌/型号/代理商价格信息') |
395 | 396 |
verbose_name_plural = _(u'品牌/型号/代理商价格信息') |
397 |
+ |
|
396 | 398 |
unique_together = ( |
397 | 399 |
('brand_id', 'model_id', 'distributor_id'), |
398 | 400 |
) |
@@ -109,7 +109,9 @@ class SystemMessageReadInfo(BaseModelMixin): |
||
109 | 109 |
verbose_name = _('systemmessagereadinfo') |
110 | 110 |
verbose_name_plural = _('systemmessagereadinfo') |
111 | 111 |
|
112 |
- unique_together = (('user_id', 'msg_id'),) |
|
112 |
+ unique_together = ( |
|
113 |
+ ('user_id', 'msg_id'), |
|
114 |
+ ) |
|
113 | 115 |
|
114 | 116 |
def __unicode__(self): |
115 | 117 |
return unicode(self.pk) |
@@ -123,7 +125,9 @@ class SystemMessageDeleteInfo(BaseModelMixin): |
||
123 | 125 |
verbose_name = _('systemmessagedeleteinfo') |
124 | 126 |
verbose_name_plural = _('systemmessagedeleteinfo') |
125 | 127 |
|
126 |
- unique_together = (('user_id', 'msg_id'),) |
|
128 |
+ unique_together = ( |
|
129 |
+ ('user_id', 'msg_id'), |
|
130 |
+ ) |
|
127 | 131 |
|
128 | 132 |
def __unicode__(self): |
129 | 133 |
return unicode(self.pk) |
@@ -66,9 +66,11 @@ class PhotosInfo(BaseModelMixin): |
||
66 | 66 |
class Meta: |
67 | 67 |
verbose_name = _('photosinfo') |
68 | 68 |
verbose_name_plural = _('photosinfo') |
69 |
+ |
|
69 | 70 |
index_together = [ |
70 | 71 |
['lensman_id', 'session_id'], |
71 | 72 |
] |
73 |
+ |
|
72 | 74 |
unique_together = ( |
73 | 75 |
('lensman_id', 'session_id', 'photo_id'), |
74 | 76 |
) |
@@ -29,6 +29,9 @@ class SalesResponsibilityInfo(BaseModelMixin): |
||
29 | 29 |
sr_id = ShortUUIDField(_(u'sr_id'), max_length=32, blank=True, null=True, help_text=u'销售担当唯一标识', db_index=True, unique=True) |
30 | 30 |
|
31 | 31 |
user_id = models.CharField(_(u'user_id'), max_length=32, blank=True, null=True, help_text=u'用户唯一标识', db_index=True) |
32 |
+ unionid = models.CharField(_(u'unionid'), max_length=32, blank=True, null=True, help_text=u'微信 UnionID', db_index=True) |
|
33 |
+ openid = models.CharField(_(u'openid'), max_length=32, blank=True, null=True, help_text=u'微信 OpenID', db_index=True) |
|
34 |
+ |
|
32 | 35 |
name = models.CharField(_(u'name'), max_length=255, blank=True, null=True, help_text=u'销售担当姓名') |
33 | 36 |
phone = models.CharField(_(u'phone'), max_length=11, blank=True, null=True, help_text=u'销售担当联系电话') |
34 | 37 |
|
@@ -44,7 +47,7 @@ class SalesResponsibilityInfo(BaseModelMixin): |
||
44 | 47 |
verbose_name_plural = _(u'销售担当信息') |
45 | 48 |
|
46 | 49 |
unique_together = ( |
47 |
- ('brand_id', 'sr_id'), |
|
50 |
+ ('unionid', 'brand_id'), |
|
48 | 51 |
) |
49 | 52 |
|
50 | 53 |
def __unicode__(self): |
@@ -7,9 +7,10 @@ from django_logit import logit |
||
7 | 7 |
from django_response import response |
8 | 8 |
from TimeConvert import TimeConvert as tc |
9 | 9 |
|
10 |
+from account.models import UserInfo |
|
10 | 11 |
from mch.models import DistributorInfo |
11 | 12 |
from sales.models import SalesResponsibilityInfo, SalesResponsibilityInfoModelsSaleStatisticInfo, SuperSalesResponsibilityInfoModelsSaleStatisticInfo |
12 |
-from utils.error.errno_utils import SalesResponsibilityStatusCode |
|
13 |
+from utils.error.errno_utils import UserStatusCode, SalesResponsibilityStatusCode |
|
13 | 14 |
|
14 | 15 |
|
15 | 16 |
@logit |
@@ -22,7 +23,14 @@ def sr_submit_api(request): |
||
22 | 23 |
if SalesResponsibilityInfo.objects.filter(brand_id=brand_id, phone=phone).exclude(user_id=user_id).exists(): |
23 | 24 |
return response(SalesResponsibilityStatusCode.SR_PHONE_ALREADY_EXISTS) |
24 | 25 |
|
25 |
- SalesResponsibilityInfo.objects.update_or_create(brand_id=brand_id, user_id=user_id, defaults={ |
|
26 |
+ try: |
|
27 |
+ user = UserInfo.objects.get(user_id=user_id) |
|
28 |
+ except UserInfo.DoesNotExist: |
|
29 |
+ return response(UserStatusCode.USER_NOT_FOUND) |
|
30 |
+ |
|
31 |
+ SalesResponsibilityInfo.objects.update_or_create(unionid=user.unionid, brand_id=brand_id, defaults={ |
|
32 |
+ 'user_id': user.user_id, |
|
33 |
+ 'openid': user.openid, |
|
26 | 34 |
'name': name, |
27 | 35 |
'phone': phone, |
28 | 36 |
'user_status': SalesResponsibilityInfo.UNVERIFIED, |